package com.ruoyi.recruit.controller;

import com.ruoyi.api.system.utils.ShiroUtils;
import com.ruoyi.api.system.utils.poi.ExcelUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.recruit.constant.RecruitConstants;
import com.ruoyi.recruit.domain.RecruitContent;
import com.ruoyi.recruit.domain.RecruitInfo;
import com.ruoyi.recruit.service.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.bouncycastle.math.raw.Mod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 招聘内容Controller
 * 
 * @author ruoyi
 * @date 2022-05-03
 */
@Controller
@RequestMapping("/recruit/report")
public class RecruitReportController extends BaseController
{
    private String prefix = "recruit/report";

    @Autowired
    private IRecruitContentService recruitContentService;

    @Autowired
    private IRecruitInfoService recruitInfoService;

    @RequiresPermissions("recruit:report:view")
    @GetMapping()
    public String report(ModelMap mmap)
    {
        mmap.put("infos", recruitInfoService.selectRecruitInfoList(new RecruitInfo()));
        return prefix + "/report";
    }

    /**
     * 查询招聘信息列表
     */
    @RequiresPermissions("recruit:report:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecruitContent recruitContent)
    {
        startPage();
        List<RecruitContent> list = recruitContentService.selectRecruitContentByEmpty(recruitContent);
        return getDataTable(list);
    }

    /**
     * 导出招聘内容列表
     */
    @RequiresPermissions("recruit:report:export")
    @Log(title = "空岗情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecruitContent recruitContent)
    {
        List<RecruitContent> list = recruitContentService.selectRecruitContentByEmpty(recruitContent);
        ExcelUtil<RecruitContent> util = new ExcelUtil<RecruitContent>(RecruitContent.class);
        return util.exportExcel(list, "空岗内容数据");
    }
}
